﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Axis.Web.FrontEnd.Views.News;
using Axis.BusinessObject.News;
using System.Text.RegularExpressions;

namespace Axis.Web.Views.News
{
    public partial class NewsDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            CNewUI newID = new CNewUI();
            string ID = "";
            if (Request.QueryString["ID"] != null)
                ID = Request.QueryString["ID"];
            if (ID == "")
                ID = Page.RouteData.Values["ID"] as string;

            CNews item = newID.GetNewDetail(ID);
            if (item != null)
            {
                lblTitle.Text = item.Title;
                lblWritenDate.Text = item.WritenDate.ToString("HH:mm dd/MM/yyyy");
                lblContent.Text = item.Content;
                try
                {
                    string Pattent = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"
    + "<meta name=\"description\" property=\"og:description\" content=\"{0}.\" />"
    + "<meta name=\"keywords\" content=\"{1}\" />  "
     + "<meta property=\"fb:admins\" content=\"100000866764550113\" />"
                     + "<meta  property=\"og:image\" content =\"{2}\" itemprop=\"thumbnailUrl\"/>  ";
                    string description = "";
                    if (item.Summary != null)
                    {
                        Regex regex = new Regex("(<.*?>\\s*)+", RegexOptions.Singleline);
                        description = regex.Replace(item.Summary, " ").Trim();
                    }
                    HeaderPage.Text = string.Format(Pattent, description, item.Title, "http://6sao.vn" + item.ThumbnailImage);
                    TitlePage.Text = item.Title + "| Trúng thưởng | Quà tặng miễn phí | Khảo sát trực tuyến";
                }
                catch (Exception ex) { }
            }
            Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "NewsDetail",
                                string.Format("\n var NewsID={0};\n", ID), true);
        }
    }
}